home *** CD-ROM | disk | FTP | other *** search
- Path: news2.noc.netcom.net!news
- From: Tarang Deshpande <tarang@willows.com>
- Newsgroups: comp.lang.c
- Subject: Re: Q: gets, getch, and stdin
- Date: Wed, 20 Mar 1996 08:41:59 -0800
- Organization: NETCOM Network Operations
- Message-ID: <31503557.2A97@willows.com>
- References: <DnoC9w.Eq9@info.uucp>
- NNTP-Posting-Host: daffy.willows.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Chris Redekop u wrote:
- >
- >
- > while ((ch = getch()) != '\r')
- > ;
- >
- > while ((ch = getchar()) != '\n')
- > ;
-
- The reason the \n works and \r does not is because \r means carriage
- return whereas \n mean new line. \n means new line reguardless of
- what OS your using. Some OS use <CR><LF> combination for \n other
- use only <LF> and so on. So \r does not necessarily mean end of line,
- where as \n does.
-